<?php
$this->breadcrumbs=array(
	'Cadernos',
);

$this->menu=array(
	array('label'=>'Create Caderno', 'url'=>array('create')),
	array('label'=>'Manage Caderno', 'url'=>array('admin')),
);
?>

<h1>Cadernos</h1>



<?php 

$this->widget('ext.slidetoggle.ESlidetoggle',
array(
    'itemSelector' => 'div.disciplinas',
    'titleSelector' => 'div.disciplinas .title',
    //'collapsed' => 'div.disciplinas', //uncomment to show all collapsed
    //'arrow' => false, //comment to show the toggle arrow
));

$this->widget('ext.slidetoggle.ESlidetoggle',
array(
    'itemSelector' => 'div.provas',
    'titleSelector' => 'div.provas .title',
    'collapsed' => 'div.provas', //uncomment to show all collapsed
    //'arrow' => false, //comment to show the toggle arrow
));


foreach($cadernos as $caderno){
	echo "<div style='border:1px solid#EAEAEA;margin-bottom:20px;'>";
		echo "<h3>".$caderno->titulo."</h3>";
		
		echo "<div class='disciplinas' style='margin-bottom:10px;'>";
			echo "<span class='title' style='font-weight:bold;'>Assuntos</span>";
			echo "<div style='margin-left:20px;'>";
				foreach($caderno->cadernoAssuntos as $cadernoAssunto){
					echo "<span style='margin-right:5px;background-color:#dadada;'>".$cadernoAssunto->assunto->nome."({$cadernoAssunto->quantidade})</span>";
				};
			echo "</div>";
		echo "</div>";
	
	
	
		echo "<div class='provas'>";
			echo "<span class='title' style='font-weight:bold;'>Provas</span>";
			$dataProvider=new CArrayDataProvider($caderno->instancias, 
				array(
					'pagination'=>array('pageSize'=>5),
				)
			);
			$this->widget('zii.widgets.CListView', array(
				'dataProvider'=>$dataProvider,
				'itemView'=>'_cadernoInstancias',
			));
			
			echo CHtml::link('Criar nova Prova',array('criarProva','id'=>$caderno->id));
			
		echo "</div>"; 
	
	/*foreach($caderno->instancias as $instancia){
		echo '<p>'.CHtml::link('Prova '.$instancia->id, array('caderno/resolver','id'=>$instancia->id	)).'</p>';
	};*/
	
	echo "</div>";
}
/*$this->widget('zii.widgets.CListView', array(
	'model'=>$cadernos,
	'itemView'=>'_view',
)); */

?>
